<?php include"shared/head.php";
include"shared/log.php";?>

<?php

//include "shared/moudles.php";

//echo "</br>".$name;
$query=$_POST["query"];

if(empty($query))
{
    echo "<script>alert('{$plz_inpt_searchterm}')</script>";
    echo "<script>location='index.php'</script>";
}

else
{

    include "shared/conn.php";
    mysqli_select_db( $conn,"personalterm");
    mysqli_query($conn, "set names 'utf-8");

    $sql="SELECT * FROM `term` WHERE zh_CN LIKE '%$query%' OR en_US LIKE '%$query%'";
    $result=mysqli_query($conn,$sql);

    if (empty($result))
    {
        echo "<script>alert('$plz_inpt_searchterm')</script>";
        echo "<script>location='index.php'</script>";
    }
    else{

        echo "<table border='1'>
              <tr>
                  <td width='10%'>{$tb_head_id}</td>
                  <td width='30%'>{$tb_head_source}</td>
                  <td width='30%'>{$tb_head_target}</td>
                  <td width='30%'>{$tb_head_edit}</td>
                  
              </tr>";
        while($retshuzu=mysqli_fetch_array($result, MYSQLI_ASSOC))
        {
            $id=$retshuzu["id"];
            $zh_CN=$retshuzu["zh_CN"];
            $en_US=$retshuzu["en_US"];
            echo " <tr>
                  <td width='10%'>{$id}</td>
                  <td width='30%'>{$zh_CN}</td>
                  <td width='30%'>{$en_US}</td>
                  <td width='10%'>
                  <button ><a href='delete.php?tid={$id}'>{$delete}</a></button>
                  <button><a href='edit.php?tid={$id}&tsc={$zh_CN}&ttg={$en_US}'>{$edit}</a></button>
                  </td>
              </tr>";
        }

        echo "</table>";
        mysqli_close($conn);
    }



}


?>

<?php include"shared/foot.php";?>